package cn.supuwoerc.dao.impl;

import cn.supuwoerc.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository("userDao")
public class AccountDaoImpl implements AccountDao {
    @Autowired
    @Qualifier("jdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public void add(String man, double num) {
        jdbcTemplate.update("update account set money = money + ? where name = ?", num, man);
    }

    public void sub(String man, double num) {
        jdbcTemplate.update("update account set money = money - ? where name = ?", num, man);
    }
}
